package fr.mywiki.model.queries;

import java.sql.SQLException;
import java.util.ArrayList;



/**
 * Should be the place where queries are build and executed.
 * 
 * @author tlombard
 */
public class QueriesFacade {
	/**
	 * Searches for all entries whose title contains the String 'title'. Returns their identifiers.
	 * 
	 * @param title a <code>String</code> object.
	 * @return a <code>ArrayList</code> of Object[] objects.
	 * @throws SQLException if the query was not correct.
	 */
	public static ArrayList searchEntryByTitle(String title) throws SQLException {
		String sql = "SELECT id FROM entry WHERE internTitle LIKE '%"+title+"%'";
		return DatabaseAdapter.executeSelectQuery(sql).getColumn(0);
	}
	
	/**
	 * Returns all the identifiers of entries.
	 * 
	 * @return a <code>ArrayList</code> of Object[] objects.
	 * @throws SQLException if the query was not correct.
	 */
	public static ArrayList getAllEntryIds() throws SQLException {
		String sql = "SELECT id FROM entry";
		return DatabaseAdapter.executeSelectQuery(sql).getColumn(0);
	}
}
